package it.avantsoft.ls.gl.command;

import it.avantsoft.ls.gl.GroupChildHandler;

public class ReconnectCommand extends GroupChildCommand {
    private String peerId;
    private String exGroupLeaderId;

    public ReconnectCommand(GroupChildHandler child, String peerId, String exGroupLeaderId) {
        super(child);
        this.peerId = peerId;
        this.exGroupLeaderId = exGroupLeaderId;
    }

    public void execute() {
        if (getChild().isAllowed(peerId)) {
            getChild().reconnect(exGroupLeaderId, peerId);
        } else {
            //TODO send negative response
        }
    }

    public String toString() {
        return "ReconnectCommand{" +
                "child=" + getChild() +
                ", peerId='" + peerId + '\'' +
                '}';
    }
}
